package com.hr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hr.mapper.AoaDeptMapper;
import com.hr.entity.AoaDept;
import com.hr.service.AoaDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * (AoaDept)表服务实现类
 *
 * @author makejava
 * @since 2022-06-19 09:07:38
 */
@Service("aoaDeptService")
public class AoaDeptServiceImpl extends ServiceImpl<AoaDeptMapper, AoaDept> implements AoaDeptService {
    @Autowired
    private AoaDeptMapper aoaDeptMapper;

    /**
     *查询部门列表
     * @return
     */
    @Override
    public List<AoaDept> queryList() {
        return aoaDeptMapper.selectList(new QueryWrapper<>());
    }

    /**
     * 保存或修改
     * @param aoaDept
     * @return
     */
    @Override
    public boolean save(
            @RequestBody AoaDept aoaDept) {
        int row=0;
        if(aoaDept.getDeptId()==null){
            row = aoaDeptMapper.insert(aoaDept);
            return row>0;
        }
        row= aoaDeptMapper.updateById(aoaDept);
        return row>0;
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public boolean delete(Integer id) {
        int i = aoaDeptMapper.deleteById(id);
        return i>0;
    }

    /**
     * 单值查询
     * @param id
     * @return
     */
    @Override
    public AoaDept queryById(Integer id) {
        return aoaDeptMapper.selectById(id);
    }
}

